package kolekcje.eng.powtorka;

import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;

public class Jukebox {

	private ArrayList<String> songList;

	public Jukebox() {
		songList = new ArrayList<String>();
		try {
			BufferedReader br = new BufferedReader(new FileReader(JukeboxSetter.file));
			String song;
			while((song = br.readLine()) != null)
				addSong(song);
			br.close();
		} catch (FileNotFoundException e) {
			System.out.println("Nie odnaleziono pliku");
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

	private void addSong(String song) {
		String[] temp = song.split("/");
		songList.add(temp[0]);
	}

	public void printSongs() {
		for (String e : songList)
			System.out.println(e);
		System.out.println("\nposortowane:");
		Collections.sort(songList);
		for(String e : songList)
			System.out.println(e);
	}

}
